<?xml version="1.0" encoding="UTF-8" ?>

<!--
    Document   : schema2xhtml.xsl
    Created on : March 28, 2005, 9:35 PM
    Author     : alex
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:ex="http://www.infoset.org/Vocabulary/SchemaExpander/2008/1/0"
   xmlns="http://www.w3.org/1999/xhtml"
   exclude-result-prefixes="xs ex"
>

<xsl:template match="xs:element">
<xsl:call-template name="schema-element-decl"/>
</xsl:template>

<xsl:template match="xs:attribute">
<xsl:call-template name="schema-attribute-decl"/>
</xsl:template>

<xsl:template match="xs:complexType">
<xsl:call-template name="schema-complex-type-definition"/>
</xsl:template>

<xsl:template name="schema-simple-type-definition">
<div class="schema-part-type-definition">
<p>
Simple  
<span class='typename'><xsl:call-template name="namespace2prefix">
  <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
</xsl:call-template>
<xsl:value-of select="@name"/></span>
<xsl:text> restricts </xsl:text>
<xsl:for-each select="xs:restriction">
   <xsl:call-template name="ref">
     <xsl:with-param name="prefix">
       <xsl:call-template name="namespace2prefix">
         <xsl:with-param name="namespace" select="@ex:namespace"/>
       </xsl:call-template>
     </xsl:with-param>
     <xsl:with-param name="name" select="@ex:local-name"/>
     <xsl:with-param name="namespace" select="@ex:namespace"/>
     <xsl:with-param name="type">type</xsl:with-param>
   </xsl:call-template>
</xsl:for-each>
</p>
<xsl:apply-templates select="xs:restriction"/>
</div>
</xsl:template>

<xsl:template name="schema-complex-type-definition">
<div class="schema-part-type-definition">
<p>
<xsl:text>&lt;(</xsl:text>
<span class='typename'><xsl:call-template name="namespace2prefix">
  <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
</xsl:call-template>
<xsl:value-of select="@name"/></span>
<xsl:choose>
<xsl:when test="xs:complexContent">
   <xsl:for-each select="xs:complexContent/xs:extension">
     <xsl:text> extends </xsl:text>
     <xsl:call-template name="ref">
        <xsl:with-param name="prefix">
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="@ex:namespace"/>
          </xsl:call-template>
        </xsl:with-param>
        <xsl:with-param name="name" select="@ex:local-name"/>
        <xsl:with-param name="namespace" select="@ex:namespace"/>
        <xsl:with-param name="type">type</xsl:with-param>
     </xsl:call-template>
   </xsl:for-each>
   <xsl:for-each select="xs:complexContent/xs:restriction">
     <xsl:text> restricts </xsl:text>
     <xsl:call-template name="ref">
        <xsl:with-param name="prefix">
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="@ex:namespace"/>
          </xsl:call-template>
        </xsl:with-param>
        <xsl:with-param name="name" select="@ex:local-name"/>
        <xsl:with-param name="namespace" select="@ex:namespace"/>
        <xsl:with-param name="type">type</xsl:with-param>
     </xsl:call-template>
   </xsl:for-each>
</xsl:when>
<xsl:when test='xs:simpleContent'>
   <xsl:for-each select="xs:simpleContent/xs:extension">
     <xsl:text> extends </xsl:text>
     <xsl:call-template name="ref">
        <xsl:with-param name="prefix">
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="@ex:namespace"/>
          </xsl:call-template>
        </xsl:with-param>
        <xsl:with-param name="name" select="@ex:local-name"/>
        <xsl:with-param name="namespace" select="@ex:namespace"/>
        <xsl:with-param name="type">type</xsl:with-param>
     </xsl:call-template>
   </xsl:for-each>
   <xsl:for-each select="xs:simpleContent/xs:restriction">
     <xsl:text> restricts </xsl:text>
     <xsl:call-template name="ref">
        <xsl:with-param name="prefix">
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="@ex:namespace"/>
          </xsl:call-template>
        </xsl:with-param>
        <xsl:with-param name="name" select="@ex:local-name"/>
        <xsl:with-param name="namespace" select="@ex:namespace"/>
        <xsl:with-param name="type">type</xsl:with-param>
     </xsl:call-template>
   </xsl:for-each>
</xsl:when>
</xsl:choose>
<xsl:text>)</xsl:text>
<xsl:call-template name="process-complex-model-start"/>
</p>
<xsl:if test="xs:sequence | xs:choice | xs:all | xs:complexContent">
<xsl:call-template name="process-complex-model-body"/>
<p>
<xsl:text>&lt;/(</xsl:text>
<xsl:call-template name="namespace2prefix">
  <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
</xsl:call-template>
<xsl:value-of select="@name"/>
<xsl:text>)></xsl:text>
</p>
</xsl:if>
<xsl:if test=".//xs:element[xs:complexType]">
<p class="schema-part-spacer">with the following definitions of these elements:</p>
<xsl:apply-templates select=".//xs:element[xs:complexType]" mode="local-complex"/>
</xsl:if>
</div>
</xsl:template>

<xsl:template name="process-complex-model-start">
<xsl:choose>
<xsl:when test="self::*[not(*)]">/></xsl:when>
<xsl:when test="self::*[not(xs:sequence | xs:choice | xs:all | xs:complexContent)]">
<xsl:apply-templates select="." mode="attributes"/><xsl:text>/></xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="attributes"/><xsl:text>></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="process-complex-model-body">
<p>&#xa0;&#xa0;<xsl:apply-templates select="." mode="content"/></p>
</xsl:template>

<xsl:template name="namespace2prefix">
<xsl:param name="namespace"/>
<xsl:for-each select="$prefixes/ex:prefix[@namespace=$namespace]/@prefix">
   <xsl:if test="string-length(.)>0">
     <xsl:value-of select="."/>
     <xsl:text>:</xsl:text>
   </xsl:if>
</xsl:for-each>
</xsl:template>

<xsl:template name="schema-element-decl">
<xsl:choose>
<xsl:when test="xs:complexType">
  <div class="schema-part-element-decl">
  <p><xsl:text>&lt;</xsl:text><span class="elementname">
  <xsl:call-template name="namespace2prefix">
    <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
  </xsl:call-template>
  <xsl:value-of select="@name"/></span>
  <xsl:for-each select="xs:complexType">
  <xsl:call-template name="process-complex-model-start"/>
  </xsl:for-each>
  </p>
  <xsl:if test="xs:complexType[xs:sequence | xs:choice | xs:all ]">
  <xsl:for-each select="xs:complexType">
  <xsl:call-template name="process-complex-model-body"/>
  </xsl:for-each>
  <p><xsl:text>&lt;/</xsl:text>
  <xsl:call-template name="namespace2prefix">
    <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
  </xsl:call-template>
  <xsl:value-of select="@name"/>></p>
  </xsl:if>
  <xsl:if test="xs:complexType//xs:element/xs:complexType">
  <p class="schema-part-spacer">with the following definitions of these elements:</p>
  <xsl:apply-templates select="xs:complexType//xs:element[xs:complexType]" mode="local-complex"/>
  </xsl:if>
  </div>
</xsl:when>
<xsl:otherwise>
  <div class="schema-part-element-decl">
  <xsl:choose>
     <xsl:when test="@ex:namespace='http://www.w3.org/2001/XMLSchema'">
     <p><xsl:text>&lt;</xsl:text><span class="elementname">
     <xsl:call-template name="namespace2prefix">
        <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
     </xsl:call-template>
     <xsl:value-of select="@name"/></span>>{type <xsl:value-of select="@type"/><xsl:text>}&lt;/</xsl:text>
     <xsl:call-template name="namespace2prefix">
        <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
     </xsl:call-template>
     <xsl:value-of select="@name"/>></p>
     </xsl:when>
     <xsl:when test="not(@type)">
        <xsl:text>&lt;</xsl:text><span class="elementname">
        <xsl:call-template name="namespace2prefix">
          <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
        </xsl:call-template>
        <xsl:value-of select="@name"/></span><xsl:text>/>{type xs:anyType}</xsl:text>
     </xsl:when>
     <xsl:otherwise>
     <p><xsl:text>&lt;</xsl:text><span class="elementname">
     <xsl:call-template name="namespace2prefix">
       <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
     </xsl:call-template>
     <xsl:value-of select="@name"/>
     </span>
     <xsl:text> .../>{type </xsl:text>
     <xsl:call-template name="ref">
        <xsl:with-param name="prefix">
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="@ex:namespace"/>
          </xsl:call-template>
        </xsl:with-param>
        <xsl:with-param name="name" select="@ex:local-name"/>
        <xsl:with-param name="namespace" select="@ex:namespace"/>
        <xsl:with-param name="type">type</xsl:with-param>
     </xsl:call-template>
     <xsl:text>}</xsl:text>
     </p>
     </xsl:otherwise>
  </xsl:choose>
  </div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="schema-attribute-decl">
<div class="schema-part-attribute-decl">
<p>Global attribute: 
<xsl:apply-templates select="." mode="attributes"/>
</p>
</div>
</xsl:template>

<xsl:template match="xs:element/xs:complexType" mode="attributes">
<xsl:apply-templates select="xs:attribute|xs:anyAttribute|xs:simpleContent/xs:extension/xs:attribute|xs:simpleContent/xs:extension/xs:anyAttribute"
                     mode="attributes"/>
</xsl:template>

<xsl:template match="xs:attribute[@ref]" mode="attributes">
<br/>&#xa0;&#xa0;
{ <xsl:value-of select="@ref"/> }
&#xa0;
</xsl:template>

<xsl:template match="xs:attribute" mode="attributes">
<br/>&#xa0;&#xa0;
<span>
<xsl:if test="@use='required'"><xsl:attribute name="class">schema-part-reqatt</xsl:attribute></xsl:if>
<xsl:value-of select="@name"/></span> = <xsl:value-of select="@type"/>
<xsl:if test="@default"> : "<xsl:value-of select="@default"/>"</xsl:if>
&#xa0;
</xsl:template>

<xsl:template match="xs:anyAttribute[@namespace='##any' or not(@namespace)]" mode="attributes">
<br/><xsl:text>&#xa0;&#xa0;{any attribute}</xsl:text>
</xsl:template>

<xsl:template match="xs:anyAttribute" mode="attributes">
<br/><xsl:text>&#xa0;&#xa0;{any attribute in </xsl:text><xsl:value-of select="@namespace"/><xsl:text>}</xsl:text>
</xsl:template>

<xsl:template match="xs:complexContent/xs:extension" mode="attributes">
<xsl:variable name="namespace" select="@ex:namespace"/>
<xsl:variable name="lname" select="@ex:local-name"/>
<span class="from-base-type">
<xsl:apply-templates select="/ex:expanded-schema/ex:namespace[@name=$namespace]/xs:complexType[@name=$lname]/node()" mode="attributes"/>
</span>
<xsl:apply-templates select="xs:attribute" mode="attributes"/>
</xsl:template>

<xsl:template match="xs:complexType" mode="content">
<xsl:if test="@mixed='true' or @mixed='1'">
<xsl:text>{characters} | </xsl:text>
</xsl:if>
<xsl:apply-templates select="xs:sequence|xs:choice|xs:all|xs:complexContent"/>
</xsl:template>

<xsl:template match="xs:complexContent/xs:extension">
   <xsl:variable name="children" select="xs:sequence|xs:choice|xs:all"/>
   <xsl:if test="$children">(</xsl:if>
   <span class="from-base-type">
    <xsl:variable name="namespace" select="@ex:namespace"/>
    <xsl:variable name="lname" select="@ex:local-name"/>
    <xsl:for-each select="/ex:expanded-schema/ex:namespace[@name=$namespace]/xs:complexType[@name=$lname]">
       <xsl:apply-templates select="xs:sequence|xs:choice|xs:all|xs:complexContent"/>
    </xsl:for-each>
   </span>
   <xsl:if test="$children"> , </xsl:if>
   <xsl:apply-templates select="$children"/>
   <xsl:if test="$children">)</xsl:if>
</xsl:template>

<xsl:template match="xs:sequence[count(*)=1 and not(@minOccurs) and not(@maxOccurs)]">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="xs:sequence"> (<xsl:for-each select="*">
<xsl:apply-templates select="."/><xsl:if test="following-sibling::*"><xsl:text> , </xsl:text></xsl:if>
</xsl:for-each>)<xsl:call-template name="occurs"/><xsl:text> </xsl:text></xsl:template>

<xsl:template match="xs:choice"> (<xsl:for-each select="*">
<xsl:apply-templates select="."/><xsl:if test="following-sibling::*"><xsl:text> | </xsl:text></xsl:if>
</xsl:for-each>)<xsl:call-template name="occurs"/><xsl:text> </xsl:text></xsl:template>

<xsl:template match="xs:all"> (<xsl:for-each select="*">
<xsl:apply-templates select="."/><xsl:if test="following-sibling::*"><xsl:text> &amp; </xsl:text></xsl:if>
</xsl:for-each>)<xsl:call-template name="occurs"/><xsl:text> </xsl:text></xsl:template>

<xsl:template name="occurs">
<xsl:choose>
<xsl:when test="@minOccurs">
   <xsl:choose>
   <xsl:when test="@minOccurs='0' and (@maxOccurs='1' or not(@maxOccurs))">
   <xsl:text>?</xsl:text>
   </xsl:when>
   <xsl:when test="@minOccurs='0' and @maxOccurs='unbounded'">
   <xsl:text>*</xsl:text>
   </xsl:when>
   <xsl:when test="@minOccurs='1' and @maxOccurs='unbounded'">
   <xsl:text>+</xsl:text>
   </xsl:when>
   <xsl:when test="@minOccurs">
   <xsl:text>{</xsl:text><xsl:value-of select="@minOccurs"/>,<xsl:value-of select="@maxOccurs"/><xsl:text>}</xsl:text>
   </xsl:when>
   <xsl:otherwise>
   <xsl:text>{</xsl:text><xsl:value-of select="@minOccurs"/><xsl:text>,1}</xsl:text>
   </xsl:otherwise>
   </xsl:choose>
</xsl:when>
<xsl:when test="@maxOccurs">
   <xsl:choose>
   <xsl:when test="@maxOccurs='1' or not(@maxOccurs)"/>
   <xsl:when test="@maxOccurs='unbounded'">
   <xsl:text>+</xsl:text>
   </xsl:when>
   <xsl:otherwise>
   <xsl:text>{</xsl:text><xsl:value-of select="@minOccurs"/>,<xsl:value-of select="@maxOccurs"/><xsl:text>}</xsl:text>
   </xsl:otherwise>
   </xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:template>

<xsl:template match="xs:sequence/xs:element[@ref]|xs:choice/xs:element[@ref]|xs:all/xs:element[@ref]">
  <xsl:call-template name="ref">
    <xsl:with-param name="prefix">
      <xsl:call-template name="namespace2prefix">
        <xsl:with-param name="namespace" select="@ex:namespace"/>
      </xsl:call-template>
    </xsl:with-param>
    <xsl:with-param name="name" select="@ex:local-name"/>
    <xsl:with-param name="namespace" select="@ex:namespace"/>
    <xsl:with-param name="type">element</xsl:with-param>
  </xsl:call-template>
  <xsl:call-template name="occurs"/>
</xsl:template>

<xsl:template match="xs:sequence/xs:element[@type]|xs:choice/xs:element[@type]|xs:all/xs:element[@type]">
<xsl:text>&lt;</xsl:text>
<xsl:call-template name="namespace2prefix">
  <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
</xsl:call-template>
<xsl:value-of select="@name"/>
<xsl:choose>
  <xsl:when test="@ex:namespace='http://www.w3.org/2001/XMLSchema'">
    <xsl:text>>{type </xsl:text>
    <xsl:value-of select="@type"/>
    <xsl:text>}&lt;/</xsl:text>
    <xsl:call-template name="namespace2prefix">
      <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
    </xsl:call-template>
    <xsl:value-of select="@name"/>
    <xsl:text>></xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text> .../>{type </xsl:text>
    <xsl:call-template name="ref">
      <xsl:with-param name="prefix">
        <xsl:call-template name="namespace2prefix">
          <xsl:with-param name="namespace" select="@ex:namespace"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="name" select="@ex:local-name"/>
      <xsl:with-param name="namespace" select="@ex:namespace"/>
      <xsl:with-param name="type">type</xsl:with-param>
    </xsl:call-template>
    <xsl:text>}</xsl:text>
  </xsl:otherwise>
</xsl:choose>
<xsl:call-template name="occurs"/>
</xsl:template>

<xsl:template match="xs:sequence/xs:element[xs:complexType]|xs:choice/xs:element[xs:complexType]|xs:all/xs:element[xs:complexType]">
<xsl:text>&lt;</xsl:text>
<xsl:call-template name="namespace2prefix">
  <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
</xsl:call-template>
<xsl:value-of select="@name"/> .../><xsl:call-template name="occurs"/>
</xsl:template>

<xsl:template match="xs:sequence/xs:element[not(@type) and not(@ref) and not(*)]|xs:choice/xs:element[not(@type) and not(@ref)  and not(*)]|xs:all/xs:element[not(@type) and not(@ref) and not(*)]">
<xsl:text>&lt;</xsl:text>
<xsl:call-template name="namespace2prefix">
  <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
</xsl:call-template>
<xsl:value-of select="@name"/>
<xsl:text>/>{type xs:anyType}</xsl:text>
<xsl:call-template name="occurs"/>
</xsl:template>

<xsl:template match="xs:any[@namespace='##any' or not(@namespace)]">
<xsl:text>{any element}</xsl:text><xsl:call-template name="occurs"/>
</xsl:template>

<xsl:template match="xs:any">
<xsl:text>{any element in </xsl:text><xsl:value-of select="@namespace"/>}<xsl:call-template name="occurs"/>
</xsl:template>

<xsl:template match="xs:element" mode="local-complex">
<xsl:call-template name="schema-element-decl"/>
</xsl:template>

<xsl:template match="xs:annotation"/>
<xsl:template match="xs:annotation" mode="attributes"/>

<!-- documentation -->
<xsl:template name="schema-documentation">
<xsl:if test="xs:annotation/xs:documentation">
<div class="documentation">
<p class="documentation-title">Description</p>
<xsl:apply-templates select="xs:annotation/xs:documentation/node()"/>
<xsl:choose>
  <xsl:when test="self::xs:element[xs:complexType[xs:attribute[xs:annotation] or xs:complexContent/xs:extension/xs:attribute[xs:annotation]]]">
     <table class="attributes">
        <tr><th colspan="3">Attributes</th></tr>
        <tr><th>Name</th><th>Type</th><th>Description</th></tr>
        <xsl:apply-templates select="xs:complexType/xs:attribute|xs:complexType/xs:complexContent/xs:extension/xs:attribute" mode="attributes-table"/>
     </table>
  </xsl:when>
  <xsl:when test="self::xs:complexType[xs:attribute[xs:annotation] or xs:complexContent/xs:attribute[xs:annotation]]">
     <table class="attributes">
        <tr><th colspan="3">Attributes</th></tr>
        <tr><th>Name</th><th>Type</th><th>Description</th></tr>
        <xsl:apply-templates select="xs:attribute|xs:complexContent/xs:extension/xs:attribute" mode="attributes-table"/>
     </table>
  </xsl:when>
</xsl:choose>
<xsl:if test=".//xs:element[xs:annotation]">
<table class="elements">
   <tr><th colspan="2">Element Uses</th></tr>
   <tr><th>Name</th><th>Description</th></tr>
   <xsl:apply-templates select=".//xs:element[xs:annotation]" mode="elements-table"/>
</table>
</xsl:if>
</div>
</xsl:if>
</xsl:template>

<xsl:template match="xs:attribute" mode="attributes-table">
<tr>
<td><p><xsl:value-of select="@name"/></p></td>
<td>
<p>
<xsl:choose>
  <xsl:when test="@ex:namespace='http://www.w3.org/2001/XMLSchema'">
    <xsl:value-of select="@type"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:call-template name="ref">
      <xsl:with-param name="prefix">
        <xsl:call-template name="namespace2prefix">
          <xsl:with-param name="namespace" select="@ex:namespace"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="name" select="@ex:local-name"/>
      <xsl:with-param name="namespace" select="@ex:namespace"/>
      <xsl:with-param name="type">type</xsl:with-param>
    </xsl:call-template>
  </xsl:otherwise>
</xsl:choose>
</p>
</td>
<td>
<xsl:apply-templates select="xs:annotation/xs:documentation/node()"/>
</td>
</tr>
</xsl:template>

<xsl:template match="xs:element" mode="elements-table">
<tr>
<td>
   <xsl:choose>
      <xsl:when test='@ref'>
        <p>
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="@ex:namespace"/>
          </xsl:call-template>
          <xsl:value-of select="@ex:local-name"/>
        </p>
      </xsl:when>
      <xsl:otherwise>
        <p>
          <xsl:call-template name="namespace2prefix">
            <xsl:with-param name="namespace" select="ancestor::ex:namespace/@name"/>
          </xsl:call-template>
          <xsl:value-of select="@name"/>
        </p>
      </xsl:otherwise>
   </xsl:choose>
</td>
<td>
<xsl:apply-templates select="xs:annotation/xs:documentation/node()"/>
</td>
</tr>
</xsl:template>

<xsl:template match="xs:simpleType/xs:restriction">
<xsl:if test="xs:enumeration"> 
<h4>Enumerated Values</h4>
<table class='enumeration'>
   <tr><th>Value</th><th>Description</th></tr>
   <xsl:apply-templates select="xs:enumeration"/>   
</table>
</xsl:if>
<xsl:if test="xs:length|xs:minLength|xs:maxLength|xs:maxInclusive|xs:minInclusive|xs:maxExclusive|xs:minExclusive|xs:totalDigits|xs:fractionDigits|xs:whiteSpace|xs:pattern">
<h4>Constraints</h4>
<table class='constraints'>
   <tr><th>Constraint</th><th>Description</th></tr>
   <xsl:apply-templates select="xs:length|xs:minLength|xs:maxLength|xs:maxInclusive|xs:minInclusive|xs:maxExclusive|xs:minExclusive|xs:totalDigits|xs:fractionDigits|xs:whiteSpace|xs:pattern"/>   
</table>
</xsl:if>
</xsl:template>

<xsl:template match="xs:enumeration">
   <tr><td><code><xsl:value-of select='@value'/></code></td>
       <td><xsl:apply-templates select="xs:annotation/xs:documentation/node()"/><xsl:text> </xsl:text></td>
   </tr>
</xsl:template>

<xsl:template match="xs:length|xs:minLength|xs:maxLength|xs:maxInclusive|xs:minInclusive|xs:maxExclusive|xs:minExclusive|xs:totalDigits|xs:fractionDigits">
   <tr><td>
   <xsl:choose>
      <xsl:when test='local-name(.)="length"'>A length of </xsl:when>
      <xsl:when test='local-name(.)="minLength"'>A minumum length of </xsl:when>
      <xsl:when test='local-name(.)="maxLength"'>A maximum length of </xsl:when>
      <xsl:when test='local-name(.)="minInclusive"'>A minimum inclusive length of </xsl:when>
      <xsl:when test='local-name(.)="maxInclusive"'>A maximum inclusive length of </xsl:when>
      <xsl:when test='local-name(.)="minExclusive"'>A minimum exclusive length of </xsl:when>
      <xsl:when test='local-name(.)="maxExclusive"'>A maximum exclusive length of </xsl:when>
      <xsl:when test='local-name(.)="totalDigits"'>A maximum of total digits of </xsl:when>
      <xsl:when test='local-name(.)="fractionDigits"'>A maximum of fractional digits of </xsl:when>
   </xsl:choose>    
       <code><xsl:value-of select='@value'/></code> <xsl:if test='@fixed="true"'>(fixed)</xsl:if>.</td>
       <td><xsl:apply-templates select="xs:annotation/xs:documentation/node()"/><xsl:text> </xsl:text></td>
   </tr>
</xsl:template>

<xsl:template match="xs:pattern">
   <tr><td>Matches pattern <code><xsl:value-of select='@value'/></code></td>
       <td><xsl:apply-templates select="xs:annotation/xs:documentation/node()"/><xsl:text> </xsl:text></td>
   </tr>
</xsl:template>


<xsl:template match="xs:whiteSpace">
   <tr><td>Whitespace handling of <code><xsl:value-of select='@value'/></code>.</td>
       <td><xsl:apply-templates select="xs:annotation/xs:documentation/node()"/><xsl:text> </xsl:text></td>
   </tr>
</xsl:template>

</xsl:stylesheet>
